<%@page import="util.enviaEmail"%>
<%
Connection conn = null;
try {
	conn = new Conexao().getConexao();
} catch (Exception e) {
	new enviaEmail().enviar(e);
	out.print("falhaConexao");
	return;
}
%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="dao.funcionarioDao"%>
<%@page import="conexao.Conexao"%>
<%@page import="bean.funcionarioBean"%>
<%@page import="java.util.List"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="js/jquery.tablesorter.min.js"></script>
<link rel="stylesheet" href="css/blue/style.css" />
<script>
	$(function() {

		$('#tabelaUsuarios').tablesorter({
			widgets: ['zebra'],
			height:50,
			scroll: true
		});
	});
</script>
</head>
<body>
	<table id="tabelaUsuarios" class="tablesorter">
		<thead>
			<tr >
				<th width="30px">ID</th>
				<th>Nome</th>
				<th width="70px">Comissão</th>
				<th width="90px">Função</th>
				<th width="90px">Data Cadastro</th>
				<th width="58px">Ações</th>
			</tr>
		</thead>
		<tbody>
			<%
				funcionarioBean func = new funcionarioBean();
				func.setIdEmpresa((Integer) session.getAttribute("idempresa"));
				List<funcionarioBean> funcionarios = new funcionarioDao()
						.getAll(conn, func);
				if (!funcionarios.isEmpty()) {
					for (int i = 0; i < funcionarios.size(); i++) {
						SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
						String data = df.format(funcionarios.get(i).getDataCadastro());
			%>
			<tr id="<%=funcionarios.get(i).getId()%>">
				<td align="right"><%=funcionarios.get(i).getId()%></td>
				<td><%=funcionarios.get(i).getNome()%></td>
				<td align="right"><%=funcionarios.get(i).getComissao()%> %</td>
				<td><%=funcionarios.get(i).getFuncao()%></td>
				<td align="center"><%=data%></td>
				<td><div align="center"><img onclick="alterarUsuario('<%=funcionarios.get(i).getId()%>')" src="imagens/alterar.png" height="17" width="17" style="cursor: pointer;" title="alterar">
				<img onclick="excluirUsuario('<%=funcionarios.get(i).getId()%>', '<%=funcionarios.get(i).getNome()%>')" src="imagens/excluir.png" height="17" width="17" style="cursor: pointer;" title="excluir"></div></td>
			</tr>
			<%
				}
				} else {
			%>
			<tr>
				<td colspan="7" style="font-size: 13px;">Nenhum cadastro</td>
			</tr>
			<%
				}
				conn.close();
			%>
		</tbody>
	</table>
</body>
</html>